Skip to content

Split CodeQL database generation and analysis phases#521

Merged
castler merged 2 commits into
eclipse-score:mainfrom
Komal362000:koma_codeqltest
Jun 10, 2026
Merged

Split CodeQL database generation and analysis phases#521
castler merged 2 commits into
eclipse-score:mainfrom
Komal362000:koma_codeqltest

Conversation

@Komal362000

@Komal362000 Komal362000 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This PR improves CodeQL performance by splitting the Python flow into two reusable phases:

Create CodeQL database
Run CodeQL analysis
With this split, we can reuse one database and run different analysis modes:

Fast checks for PR feedback
Full checks for nightly runs
It reduces repeated work, makes CI faster, and keeps SARIF/CSV outputs as before.

Comment thread .github/workflows/codeql.yml Outdated
Comment on lines +32 to +35
push:
branches: [main]
pull_request:
branches: [main]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove, we only want to run it on a per night basis.

Comment thread .github/workflows/codeql.yml Outdated
disk-cache: "codeql"
repository-cache: true
cache-optimized: true
cache-save: ${{ github.ref == 'refs/heads/main' }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL cannot use caches, thus, we should only setup bazel but without caching.

Comment thread .github/workflows/codeql.yml Outdated
bazel run //quality/static_analysis:codeql_lint -- \
--phase create-database \
--database-path /var/tmp/codeql_databases/codeql_db \
--target //score/...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to run codeql only for two targets:

  • //score/message_passing
  • //score/mw/com

Maybe extend that mutiple targets can be supplied

Comment thread .github/workflows/codeql.yml Outdated
Comment on lines +108 to +115
- name: Setup Bazel
uses: castler/setup-bazel@cache-optimized
with:
bazelisk-cache: true
disk-cache: "codeql"
repository-cache: true
cache-optimized: true
cache-save: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No caching needed, only setup bazel please.

Comment thread .github/workflows/codeql.yml Outdated
Comment on lines +93 to +138
# ── Phase 2a: Quick analysis (PR / push to main) ────────────────────────
analyze-pr:
if: github.event_name != 'schedule'
needs: create-codeql-database
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Free Disk Space (Ubuntu)
uses: eclipse-score/more-disk-space@v1
with:
level: 4

- name: Setup Bazel
uses: castler/setup-bazel@cache-optimized
with:
bazelisk-cache: true
disk-cache: "codeql"
repository-cache: true
cache-optimized: true
cache-save: false

- name: Allow linux-sandbox
uses: ./actions/unblock_user_namespace_for_linux_sandbox

- name: Download CodeQL database
uses: actions/download-artifact@v4
with:
name: codeql-database
path: /var/tmp/codeql_databases/codeql_db

- name: Run CodeQL analysis (quick — incremental queries)
run: |
bazel run //quality/static_analysis:codeql_lint -- \
--phase analyze-database \
--database-path /var/tmp/codeql_databases/codeql_db \
--output-dir /tmp/codeql-results \
--output-prefix codeql

- name: Upload SARIF to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: /tmp/codeql-results/codeql.sarif
category: codeql-pr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can all be removed.

Comment thread .github/workflows/codeql.yml Outdated
Comment on lines +155 to +162
- name: Setup Bazel
uses: castler/setup-bazel@cache-optimized
with:
bazelisk-cache: true
disk-cache: "codeql"
repository-cache: true
cache-optimized: true
cache-save: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No caching please

Comment thread .github/workflows/codeql.yml Outdated
bazel run //quality/static_analysis:codeql_lint -- \
--phase analyze-database \
--database-path /var/tmp/codeql_databases/codeql_db \
--query-spec "codeql/misra-cpp-coding-standards@2.52.0" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this line, that we execute in CI the standard

Comment thread .github/workflows/codeql.yml
@Komal362000 Komal362000 marked this pull request as ready for review June 10, 2026 13:06
@Komal362000 Komal362000 self-assigned this Jun 10, 2026
@Komal362000 Komal362000 marked this pull request as draft June 10, 2026 13:29
@Komal362000 Komal362000 removed their assignment Jun 10, 2026
@Komal362000 Komal362000 force-pushed the koma_codeqltest branch 3 times, most recently from 13ad18b to ab953f1 Compare June 10, 2026 13:53
Run CodeQL via Bazel on all relevant C++ targets (//score/...)
on every pull_request and push to main, then upload the resulting
SARIF file to GitHub Code Scanning via github/codeql-action/upload-sarif.

Without this upload step GitHub has no stored baseline, causing every
PR to incorrectly report no new alerts introduced.

Refs: https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github
- separate create and analyze phases in codeql lint flow

- include review fixes and output handling improvements
@Komal362000

Copy link
Copy Markdown
Contributor Author

recheck

@castler castler marked this pull request as ready for review June 10, 2026 14:12
@castler castler enabled auto-merge June 10, 2026 14:12
@castler castler added this pull request to the merge queue Jun 10, 2026
Merged via the queue into eclipse-score:main with commit fed4dbf Jun 10, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants